package com.ruoyi.wms.common.enu;

import cn.hutool.core.util.ObjectUtil;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public enum ReceiptTypeEnum {
    PRODUCT("生产入库",1),
    PURCHASE("采购入库",2),
    EXIT("退货入库",3),
    RETURN("归还入库",4);
    private final String text;
    private final int value;

    ReceiptTypeEnum(String text, int value) {
        this.text = text;
        this.value = value;
    }

    /**
     * 根据value获取枚举
     * @param value
     * @return
     */
    public static ReceiptTypeEnum getEnumByValue(Integer value){
        if (ObjectUtil.isEmpty(value)){
            return null;
        }
        for (ReceiptTypeEnum anEnum : ReceiptTypeEnum.values()) {
            if (anEnum.value==value){
                return anEnum;
            }
        }
        return null;
    }

    /**
     * 获取值列表
     * @return
     */
    public static List<Integer> getValues(){
        return Arrays.stream(values()).map(item -> item.value).collect(Collectors.toList());
    }

    public String getText() {
        return text;
    }

    public int getValue() {
        return value;
    }
}
